#coding=utf-8
from django.contrib.auth.models import User
from django.db import models
from DjangoBbs.BbsTheme.models import BbsTheme
from PublicTool.BaseModel import Base_UserModel, Base_TimeModel

__author__ = 'czq'

#投票选项
class BbsThemeVoteAttr(models.Model):
    theme=models.OneToOneField(BbsTheme)
    startTime=models.DateTimeField(u'投票开始时间',null=True,blank=True)
    endTime=models.DateTimeField(u'投票结束时间',null=True,blank=True)
    totalCount=models.IntegerField(u'投票总数',default=0)


    def __unicode__(self):
        return ''
    class Meta:
        verbose_name = '投票设置'
        verbose_name_plural = '投票设置'

class BbsThemeVote(Base_TimeModel):
    theme=models.ForeignKey(BbsTheme,verbose_name=u'主题')
    content=models.CharField(u"名称",max_length=10)
    voteCount=models.IntegerField(u"票数",default=0)
    voteUsers=models.CommaSeparatedIntegerField(u'投票用户',blank=True,null=True,max_length=4000)
    rank=models.PositiveSmallIntegerField(u'排序',default=1)
    def __unicode__(self):
        return self.content
    class Meta:
        verbose_name = '投票选项'
        verbose_name_plural = '投票选项'
        ordering = ['-addTime']

class BbsThemeVoteRecord(models.Model):
    theme=models.ForeignKey(BbsTheme,verbose_name=u'主题')
    addTime=models.DateTimeField(u'添加时间',auto_now_add=True)
    #modifyTime=models.DateTimeField(u'修改时间',auto_now=True)
    addUser=models.ForeignKey(User,verbose_name=u"投票人")

    #extcredit=models.SmallIntegerField(u'获得积分',default=0)
    def __unicode__(self):
        return self.theme
    class Meta:
        verbose_name = '投票记录'
        verbose_name_plural = '投票记录'
        ordering = ['-addTime']